//
//  CCTVCheckViewController.m
//  Qihuo
//
//  Created by Vencoo on 14-1-9.
//  Copyright (c) 2014年 Vencoo. All rights reserved.
//

#import "CCTVCheckViewController.h"
#import "CCTVCell.h"
@interface CCTVCheckViewController ()
{
    NSMutableArray *checkNames;
    NSMutableArray *standars;
    NSMutableArray *results;
}
@end

@implementation CCTVCheckViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    self.checkURL = resultOfCCTV;
    self.checkNames = @[@"巡查情况",@"标准"];
    self.title = @"CCTV巡检记录";
    [super viewDidLoad];
    checkNames = [NSMutableArray array];
    standars = [NSMutableArray array];
    results = [NSMutableArray array];
}
#pragma mark - request
- (void)requestDone:(ASIFormDataRequest *)request
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    NSString *response = [request responseString];
    NSDictionary *queryDic = [response JSONValue];
    NSLog(@"查询%@",queryDic);
    NSDictionary *queryDataArr = [queryDic objectForKey:@"data"];
    NSArray *floorData = [queryDataArr objectForKey:@"floorData"];
    
    
    for (int i = 0; i < floorData.count; i ++)
    {
        NSDictionary *queryDic = [floorData objectAtIndex:i];
        [checkNames addObject:queryDic[@"checkName"]];
        [standars addObject:queryDic[@"Standard"]];
        [results addObject:queryDic[@"result"]];
    }
    [self.mainTable reloadData];
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return checkNames.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"cell";
    CCTVCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell)
    {
        cell = [[CCTVCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        //        UILabel *floorNameLb = [UILabel new];
        //        floorNameLb.text = [[self.secondFloorNames objectAtIndex:indexPath.section]objectAtIndex:indexPath.row];
        //        floorNameLb.font = [UIFont systemFontOfSize:20];
        //        CGSize cgSZ = [floorNameLb.text sizeWithFont:floorNameLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
        //        floorNameLb.frame = CGRectMake(0, (cell.frame.size.height - cgSZ.height)/2, cgSZ.width, cgSZ.height);
        //        [cell.contentView addSubview:floorNameLb];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.longFloorNameLb.text = checkNames[indexPath.row];
    cell.resultLb.text = results[indexPath.row];
    cell.processLb.text = standars[indexPath.row];
    return cell;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
